package enterprise.web.tookit.attachment;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.PostLoad;
import javax.persistence.PostPersist;
import javax.persistence.PostRemove;
import javax.persistence.PostUpdate;
import javax.persistence.PrePersist;
import javax.persistence.PreRemove;
import javax.persistence.PreUpdate;

import org.apache.log4j.Logger;

/**
 * @since 01/09/2012
 * 
 * @author regisrocha
 * 
 * @description Classe para mapeamento da entidade enterprisewebtoolkit_db.Attachment
 * 
 */
@Entity(name = "attachment")
public class Attachment implements Serializable {

	/**
	 * serial version
	 */
	private static final long serialVersionUID = -3658345540894254557L;

	/**
	 * LOG
	 */
	private final static Logger log = Logger.getLogger(Attachment.class);

	private Integer id;
	private String url;
	private String path;
	private String name;
	private String description;

	/**
	 * @return the id
	 */
	@Id
	@GeneratedValue
	@Column(name = "id")
	public Integer getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 * @return the url
	 */
	@Column(name = "url", length = 255)
	public String getUrl() {
		return url;
	}

	/**
	 * @param url
	 *            the url to set
	 */
	public void setUrl(String url) {
		this.url = url;
	}

	/**
	 * @return the path
	 */
	@Column(name = "path", length = 255)
	public String getPath() {
		return path;
	}

	/**
	 * @param path
	 *            the path to set
	 */
	public void setPath(String path) {
		this.path = path;
	}

	/**
	 * @return the name
	 */
	@Column(name = "name", length = 255)
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the description
	 */
	@Column(name = "description", length = 255)
	public String getDescription() {
		return description;
	}

	/**
	 * @param description
	 *            the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	@Override
	public String toString() {
		final StringBuilder toString = new StringBuilder();

		toString.append(" ID: " + this.id);
		toString.append(" URL: " + this.url);
		toString.append(" NAME: " + this.name);
		toString.append(" PATH: " + this.path);
		toString.append(" DESCRIPTION: " + this.description);

		return toString.toString();
	}

	@PostLoad
	public void postLoad() {
		log.info("Loading attachment: " + this.toString());
	}

	@PrePersist
	public void prePersist() {
		log.info("Persisting attachment: " + this.toString());
	}

	@PostPersist
	public void postPersist() {
		log.info("Attachment persisted, ID: " + this.id);
	}

	@PreUpdate
	public void preUpdate() {
		log.info("Pre updating attachment: " + this.toString());
	}

	@PostUpdate
	public void postUpdate() {
		log.info("Attachment updated, iD: " + this.id);
	}

	@PreRemove
	public void preRemove() {
		log.info("Pre removing attachment: " + this.toString());
	}

	@PostRemove
	public void postRemove() {
		log.info("Attachment Removed, name: " + this.name);
	}
}
